<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/system/common.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/system/accountforcustomer.js"></script>
<script type="text/javascript">
    $(function () {
        //设置text需要验证
        $('#pwd').validatebox();
    })
    var fg=true;
    $.extend($.fn.validatebox.defaults.rules, {
        //验证(只能包括 _ 数字 字母)
        password: {//param的值为[]中值
            validator: function (value, param) {
                if (!/^[\w]+$/.test(value)) {
                    $.fn.validatebox.defaults.rules.account.message = '密码只能数字、字母、下划线组成.';
                    fg=false;
                    return false;
                } else {
                    if (value.length < param[0] || value.length > param[1]) {
                        $.fn.validatebox.defaults.rules.account.message = '用户密码长度必须在' + param[0] + '至' + param[1] + '范围';
                        fg=false;
                        return false;
                    } else {
                        fg=true;
                        return true;
                    }
                }
            }, message: ''
        }
    })

    var mfg=true;
    $.extend($.fn.validatebox.defaults.rules, {
        //验证(只能包括 _ 数字 字母)
        account: {//param的值为[]中值
            validator: function (value, param) {
                if (!/^[\w]+$/.test(value)) {
                    $.fn.validatebox.defaults.rules.account.message = '只能数字、字母、下划线组成.';
                    mfg=false;
                    return false;
                } else {
                    if (value.length < param[0] || value.length > param[1]) {
                        $.fn.validatebox.defaults.rules.account.message = '长度必须在' + param[0] + '至' + param[1] + '范围';
                        mfg=false;
                        return false;
                    } else {
                        mfg=true;
                        return true;
                    }
                }
            }, message: ''
        }
    })

    $.extend($.fn.validatebox.defaults.rules, {
        phoneNum: { //验证手机号
            validator: function(value, param){
                // return /^1[3-8]+\d{9}$/.test(value);
                return validatePhoneVal(value);
            },
            message: '请输入正确的手机号码。'
        }
    });
    $.extend($.fn.validatebox.defaults.rules, {
        identitycard: { //验证身份证号
            validator: function(value, param){
                return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(value);
            },
            message: '请输入正确的身份证'
        }
    });
    $.extend($.fn.validatebox.defaults.rules, {
        moneyNum: { //验证资金量
            validator: function(value, param){
                return /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/.test(value);
            },
            message: '请输入正整数或小数'
        }
    });
    $.extend($.fn.validatebox.defaults.rules, {
        agr: { //验证年龄
            validator: function(value, param){
                return /^[0-9]*$/.test(value);
            },
            message: '请输入数字'
        }
    });
    $.extend($.fn.validatebox.defaults.rules, {
        exp: { //验证有效时间
            validator: function(value, param){
                const level=$("input[name='userlevel']").val();
                const isnum=!/^[0-9]*$/.test(value);
                if (isnum) {
                    $.fn.validatebox.defaults.rules.exp.message = '只能输入正整数';
                    return false;
                }
                if(value>36500){
                    $.fn.validatebox.defaults.rules.exp.message = '输入超过最大值';
                    return false;
                }
                return true;


            },
            message: ''
        }
    });
</script>
<div id="accountforcustomer-tool-bar" style="padding: 10px 10px 0 10px">
    <form id="accountforcustomer-search-form">
        <span id="inselectedloginName" style="display: none;"><shiro:principal property="loginName"/></span>
        <div class="easyui-linkbutton " id="accountforcustomer-flash-btn" data-options="iconCls:'icon-reload'" style="width:70px">刷新</div>
        <div class="easyui-linkbutton " id="accountforcustomer-save-btn" data-options="iconCls:'icon-add'" style="width:70px">开号</div>
        <div class="easyui-linkbutton " id="accountforcustomer-update-btn" data-options="iconCls:'icon-edit'" style="width:70px">修改</div>
        <div class="easyui-linkbutton " id="accountforcustomer-delete-btn" data-options="iconCls:'icon-remove'" style="width:70px">删除</div>
        <span style="line-height: 26px; ">登录账号:<input name="accountforcustomer-search-loginName" class="easyui-textbox"
                                                     style="line-height: 26px; "></span>
        <span style="line-height: 26px; ">中文名:<input name="accountforcustomer-search-username" class="easyui-textbox"
                                                     style="line-height: 26px; "></span>
        <span style="line-height: 26px; ">手机号码:<input name="accountforcustomer-search-phone" class="easyui-numberbox"
                                                    style="line-height: 26px; "></span>&nbsp;
        <div class="easyui-linkbutton " id="accountforcustomer-select-btn" data-options="iconCls:'icon-search'" style="width:70px">搜索
        </div>
        <div class="easyui-linkbutton " id="accountforcustomer-clear-btn" data-options="iconCls:'icon-cancel'" style="width:60px">清空
        </div>
    </form>
</div>
<div id="accountforcustomer_grid" style="padding: 10px">

</div>
<div id="accountforcustomer_edit_dialog" style="display: none;">
    <form id="accountforcustomer_form">
        <input type="hidden" name="id" id="id">
        <span id="loginName" style="display: none;"><shiro:principal property="loginName"/></span>
        <div style="float: left;height: 290px;">
            <p style="padding: 10px ;">&nbsp;中&nbsp;&nbsp;文&nbsp;&nbsp;名:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="username" id="username"
                                                        style="width: 300px;height: 35px"
                                                        data-options="required:true"
                                                        class="easyui-textbox easyui-validatebox" ></p>
            <p style="padding: 10px;">&nbsp;&nbsp;登录账号:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="userid" id="userid" style="width: 300px;height: 35px"
                                                       data-options="required:true,validType:'account[6,20]'"
                                                       class="easyui-textbox easyui-validatebox"></p>
            <p style="padding: 10px ;">&nbsp;&nbsp;登录密码:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="pwd" type="password" id="pwd"
                                                             style="width: 300px;height: 35px"
                                                             data-options="required:true,validType:'account[6,16]'"
                                                             class="easyui-textbox easyui-validatebox"></p>

            <p style="padding: 10px ;">&nbsp;&nbsp;指标权限:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select name="userlevel" id="userlevel"
                                                              style="width: 300px;height: 35px"
                                                              data-options="required:true,editable:false"
                                                              class="easyui-combobox easyui-validatebox">
                <option value="0" >体验账户</option>
<%--                <option value="1">租用账户</option>--%>
                <option value="2">经典账户</option>
                <option value="3">尊享账户</option>
                <option value="4">标准账户</option>
                <option value="5">待定账户1</option>
                <option value="6">待定账户2</option>
            </select></p>
            <p style="padding: 10px ;">&nbsp;&nbsp;有效时间:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input name="exp" id="exp"
                       style="width: 300px;height: 35px"
                       data-options="required:true,prompt:'请输入符合账户级别的有效时间。',validType:'exp'"
                       class="easyui-textbox easyui-validatebox" ></p>
            <p style="padding: 10px ;">&nbsp;&nbsp;性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select name="sex" id="sex"
                                                              style="width: 300px;height: 35px"
                                                              data-options="required:true,editable:false"
                                                              class="easyui-combobox easyui-validatebox">
                <option value="1">男</option>
                <option value="2">女</option>
            </select>
            <p style="padding: 10px ;">&nbsp;&nbsp;身&nbsp;&nbsp;份&nbsp;&nbsp;&nbsp;证:&nbsp;&nbsp;&nbsp;&nbsp;<input name="identitycard" id="identitycard"
                                                             style="width: 300px;height: 35px"
                                                             data-options="required:false,validType:'identitycard'"
                                                             class="easyui-textbox easyui-validatebox" ></p>
            <p style="padding: 10px ;">&nbsp;&nbsp;年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;龄:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="age" id="age" style="width: 300px;height: 35px" data-options="required:false,validType:'age'" class="easyui-textbox easyui-validatebox" ></p>
            <p style="padding: 10px ;">&nbsp;&nbsp;资&nbsp;&nbsp;金&nbsp;&nbsp;量:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="money" id="money"
                                                             style="width: 300px;height: 35px"
                                                             data-options="required:false,prompt:'单位:万',validType:'moneyNum'"
                                                             class="easyui-textbox easyui-validatebox" ></p>
            <%--data-options="required:false,validType:['email']"--%>
            <p style="padding: 10px ;">&nbsp;&nbsp;手机号码:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="phone" id="phone"
                                                             style="width: 300px;height: 35px"
                                                             data-options="required:true,prompt:'请输入正确的手机号码。',validType:'phoneNum'"
                                                             class="easyui-textbox easyui-validatebox" ></p>
            <p style="padding: 10px ;">&nbsp;&nbsp;地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input id="a1forcustomer_address" name='a1forcustomer_address' class="easyui-combobox" style="width: 150px">
                <input id="a2forcustomer_address" class="easyui-combobox" style="width: 150px">
            </p>

        </div>



    </form>
</div>


